package org.kingtop.shiro.util;

import org.kingtop.action.ResultBean;
import org.kingtop.util.JsonUtil;

import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 陈金波
 * @date 2018/2/10 19:59
 */
public class ShiroUtil {

    /**
     * 输出没有结果的json格式消息
     * @param result 结果
     * @param response response
     * @throws IOException 异常
     */
    public static void writeUnauthorityMessage(ResultBean<String> result, ServletResponse response) throws IOException {
        try(PrintWriter writer = response.getWriter();) {
            writer.println(JsonUtil.toString(result));
        }catch (Exception e) {
            e.printStackTrace();
            throw new IOException(e);
        }
    }

}
